package com.ctsi.organise.common.api;


import com.ctsi.framework.common.startrun.ComponentFactory;

/**
 * @author: zhangjw
 * @Date: 2018/11/6 15:39
 * @Description:
 */
public class OrganiseFactoryBean {

    static class OrgRef{
        static final OrganiseServiceProxy organiseProxy = createObjectByFact( OrganiseServiceProxy.class.getSimpleName(), OrganiseServiceProxy.class);
        static final PersonServiceProxy personProxy = createObjectByFact( PersonServiceProxy.class.getSimpleName(), PersonServiceProxy.class);
        static final RoleServiceProxy roleProxy = createObjectByFact( RoleServiceProxy.class.getSimpleName(), RoleServiceProxy.class);
        static final UserLoginServiceProxy userLoginProxy = createObjectByFact( UserLoginServiceProxy.class.getSimpleName(), UserLoginServiceProxy.class);
    }
    private static final OrganiseFactoryBean factory = new OrganiseFactoryBean();

    protected OrganiseFactoryBean() {
    }

    public static final OrganiseFactoryBean getInstance() {
        return factory;
    }

    protected  static final <T> T createObjectByFact(  String name, Class<T> clazz) {
        return ComponentFactory.getBean(name, clazz);
    }

    public OrganiseServiceProxy getOrganiseProxy() {
        return OrgRef.organiseProxy;
    }


    public RoleServiceProxy getRoleProxy() {
        return OrgRef.roleProxy;
    }


    public UserLoginServiceProxy getUserLoginProxy() {
        return OrgRef.userLoginProxy;
    }

    public PersonServiceProxy getPersonServiceProxy(){
        return OrgRef.personProxy;
    }
}
